/*
 * Copyright (c) 2010 CCX(China) Co.,Ltd. All Rights Reserved.
 *
 * This software is the confidential and proprietary information of
 * CCX(China) Co.,Ltd. ("Confidential Information").
 * It may not be copied or reproduced in any manner without the express 
 * written permission of CCX(China) Co.,Ltd.
 * 
 *	Created on 2010-12-22 下午04:19:10
 */
package cn.com.ccxe.core.entity;

import java.util.List;

/**
 * 网页.
 * 网页将会根据域名设定层级结构。如网易(http://www.163.com)为顶级模块，
 * 而它的体育(http://sports.163.com)、财经(http://money.163.com)等模块将为他的一级模块，而财经下面有划分为股票、宏观经济等，
 * 最底层的模块将是列表页。
 *
 * @author hetao
 */
public class Website {

	private int id;						//ID
	private int parentId;				//父ID，默认为0，0为顶级模块
	private String name;				//名称
	private String path;				//网站路径
	private String discription;			//描述
	private short isList;				//是否为列表数据，默认为0，0为否，1为是
	private short isMonitor;			//是否监听 默认为1，0为否，1为是
	private CrawlExpression listPage;	//列表页面内容提取时的表达式
	private Website	parent;
	private List<Website> children;
	
	public Website() {
		//设置默认值
		parentId = 0;
		isList = 0;
		isMonitor = 1;
	}
	public Website(int id) {
		this();
		this.id = id;
	}
	
	
	@Override
	public int hashCode() {
		int result = 17;
		result = 31 * result + id;
		result = 31 * result + parentId;
		result = 31 * result + name.hashCode();
		result = 31 * result + path.hashCode();
		result = 31 * result + isList;
		result = 31 * result + isMonitor;
		return result;
	}
	
	@Override
	public boolean equals(Object obj) {
		if(obj instanceof Website) {
			Website a = (Website) obj;
			return a.id == id && a.parentId == parentId
					&& a.isList == isList && a.isMonitor == a.isMonitor
					&& a.name.equals(name) && a.path.equals(path); 
		}
		return false;
	}
	
	@Override
	public String toString() {
		return "id:"+id+",name:"+name+",url:"+path;
	}

	/*       GET METHOD       */
	public int getId() {return id;}
	public int getParentId() {return parentId;}
	public String getName() {return name;}
	public String getPath() {return path;}
	public String getDiscription() {return discription;}
	public short getIsList() {return isList;}
	public short getIsMonitor() {return isMonitor;}
	public CrawlExpression getListPage() {	return listPage;}
	public Website getParent() {return parent;}
	public List<Website> getChildren() {return children;}
	
	/*       SET METHOD       */
	public void setId(int id) {this.id = id;}
	public void setParentId(int parentId) {this.parentId = parentId;}
	public void setName(String name) {this.name = name;}
	public void setPath(String path) {this.path = path;}
	public void setDiscription(String discription) {this.discription = discription;}
	public void setIsList(short isList) {this.isList = isList;}
	public void setIsMonitor(short isMonitor) {this.isMonitor = isMonitor;}
	public void setListPage(CrawlExpression listPage) {this.listPage = listPage;}
	public void setParent(Website parent) {	this.parent = parent;}
	public void setChildren(List<Website> children) {this.children = children;}
	
}
